import request from "@/utils/request";

//封装用户注册接口
export const regUserApi = (data) => {
  return request({
    method: "post",
    url: "/api/reg",
    data,
  });
};

// 封装用户登录接口
export const loginApi = (data) => {
  return request({
    method: "post",
    url: "/api/login",
    data,
  });
};

// 封装获取用户信息接口
export const getUserInfoApi = () => {
  //获取pinia中模块对象，.vue文件中写在开头
  // js文件要写在函数内部，否则会报错，没有初始化完毕

  return request({
    method: "get",
    url: "/my/userinfo",
  });
};

// 更新用户资料接口
export const updateUserInfoApi = (data) => {
  return request({
    method: "put",
    url: "/my/userinfo",
    data,
  });
};

// 更新用户头像接口
export const updateUserAvatarApi = (data) => {
  return request({
    method: "patch",
    url: "/my/update/avatar",
    data,
  });
};

// 更新用户密码
export const updateUserPwdApi = (data) => {
  return request({
    method: "patch",
    url: "/my/updatepwd",
    data,
  });
};
